<?xml version='1.0' encoding='utf-8' ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
		<title>extensibillitymodeling</title>
		<link type="text/css" rel="stylesheet" href="PLUGINS_ROOT/org.polarsys.kitalpha.doc/html/common/style/style.css"/>
	</head>
	<body>
		<h1 id="Modeling_the_models_extensibility_and_extensions"><center> Modeling the models extensibility and extensions </center></h1>
		<p>This section focus on how to make an ECLass extensible by the eMDE mechanism and how to contribute with new extensions</p>
		<p>Let take the following example to ilustate all the steps. </p>
		<table border="1">
			<tr>
				<td>
					<b>The ecore model <code>A</code></b> contains two EClasses: <code>Project</code> and <code>Component</code>. The first one is the model root element. It contains the containment EReference <code>ownedComponents</code>. That reference will be used to store all the <code>Components</code> of a project.
					<p>The 
						<b>Ns URI</b> is http://www.polarsys.org/kitalpha/a/
					</p>
				</td>
				<td>
					<div class="thumb">
						<div class="thumbinner" style="width:402px;">
							<a href="../img/ecore_a.png" class="image">
								<img class="thumbimage" width="400" border="0" src="../img/ecore_a.png"/>
							</a>
						</div>
					</div> 
				</td>
			</tr>
			<tr>
				<td>
					<b>The ecore model <code>B</code></b> contains the EClass <code>ComponentExtension</code>.
					<p>The 
						<b>Ns URI</b> is http://www.polarsys.org/kitalpha/b/
					</p>
				</td>
				<td>
					<div class="thumb">
						<div class="thumbinner" style="width:402px;">
							<a href="../img/ecore_b.png" class="image">
								<img class="thumbimage" width="400" border="0" src="../img/ecore_b.png"/>
							</a>
						</div>
					</div>
				</td>
			</tr>
		</table>
		<h2 id="Content">Content</h2>
		<ol>
			<li>
				<a href="#Making_an_EClass_as_extensible">Making an EClass as extensible</a>
			</li>
			<li>
				<a href="#Defining_an_ECLass_as_an_extension_to_an_other_one">Defining an ECLass as an extension to an other one</a>
				<ol>
					<li>
						<a href="#EAnnotation_for_the_EPackage">EAnnotation for the EPackage</a>
					</li>
					<li>
						<a href="#EAnnotations_for_the_EClass">EAnnotations for the EClass</a>
					</li>
					<li>
						<a href="#Using_the_Extensibility_graphical_designer">Using the Extensibility graphical designer</a>
					</li>
					<li>
						<a href="#Example">Example</a>
					</li>
				</ol>
			</li>
		</ol>
		<h2 id="Making_an_EClass_as_extensible">Making an EClass as extensible</h2>
		<p>Any EClass can be made extensible by adding <code>emde.ExtensibleElement</code> in it super classes list. To do that, one can uses the Ecore editor provided by EMF. </p>
		<p>The steps bellow is an example of making the EClass <code>a.Component</code> extensible.</p>
		<ol>
			<li>Open the A.ecore model in the ecore editor.</li>
			<li>Load the eMDE resource (its 
				<b>Ns URI</b> is http://www.polarsys.org/kitalpha/emde/1.0.0).
			</li>
			<li>Open the properties view.</li>
			<li>Select the <code>a.Component</code> EClass.</li>
			<li>Update the ESuper Types property of the <code>a.Component</code> EClass by adding <code>emde.ExtensibleElement</code> in the list.</li>
			<li>Save the modifications</li>
		</ol>
		<h2 id="Defining_an_ECLass_as_an_extension_to_an_other_one">Defining an ECLass as an extension to an other one</h2>
		<p>The definition of an EClass as an eMDE extension in managed by adding:</p>
		<ol>
			<li>EMF EAnnotations to the EPackage and the EClass to define as an extension</li>
			<li><code>emde.ElementExtension</code> as a super type of the EClass to define as an extension</li>
		</ol>
		<p>The following sections describe the different EAnotations, the extensibility graphical designer and conclude with an example.  </p>
		<h3 id="EAnnotation_for_the_EPackage">EAnnotation for the EPackage</h3>
		<p>This EAnnotation concerns the EPackage containing the EClass to be defined as extension. It aims at initializing in the ecore model some required modification to do in the genmodel. That information are stored in the EAnnotation details entries and used by the EMF generation provided by Kitalpha.</p>
		<p>The EAnnotation must have the following information:</p>
		<ol>
			<li>Source: <code>http://www.polarsys.org/kitalpha/emde/1.0.0/extension</code></li>
			<li>Detail enties:
				<ul>
					<li>
						<b>Key</b>: <code>extensibleProviderFactory</code>, 
						<b>Value</b>: <code>true</code>
					</li>
					<li>
						<b>Key</b>: <code>childCreationExtenders</code>, 
						<b>Value</b>: <code>true</code>
					</li>
					<li>
						<b>Key</b>: <code>useUUIDs</code>, 
						<b>Value</b>: <code>true</code>
					</li>
					<li>
						<b>Key</b>: <code>useIDAttributes</code>, 
						<b>Value</b>: <code>fasle</code>
					</li>
				</ul>
			</li>
		</ol>
		<p><blockquote>
			The EAnnotation for the EPackage must be added only once.
</blockquote></p>
		<h3 id="EAnnotations_for_the_EClass">EAnnotations for the EClass</h3>
		<p>These EAnnotation concerns the EClass to be defined as eMDE extension. There are two EAnnotations. The both provide an URI of the Extensible EClass. The difference between them is that the first one provides an Ns URI based URI and  the second one provides a platform based URI. </p>
		<p>The first EAnnotation must have the following information:</p>
		<ol>
			<li>Source: <code>http://www.polarsys.org/kitalpha/emde/1.0.0/constraint</code></li>
			<li>Detail enties:
				<ul>
					<li>
						<b>Key</b>: <code>ExtendedElement</code>, 
						<b>Value</b>: 
						<i>An Ns URI based URI of the extensible EClass</i>.
					</li>
				</ul>
			</li>
		</ol>
		<p>The second EAnnotation must have the following information:</p>
		<ol>
			<li>Source: <code>http://www.polarsys.org/kitalpha/emde/1.0.0/constraintMapping</code></li>
			<li>Detail enties:
				<ul>
					<li>
						<b>Key</b>: <code>Mapping</code>, 
						<b>Value</b>: 
						<i>A platform based URI of the extensible EClass</i>.
					</li>
				</ul>
			</li>
		</ol>
		<h3 id="Using_the_Extensibility_graphical_designer">Using the Extensibility graphical designer</h3>
		<p>Kitalpha provides a Sirius diagram allowing end-users to define easily the EAnnotation for EPackages and EClasses. </p>
		<p>To use that graphical designer, first, a Sirius representation should be created on the concerned ecore model. The steps are listed bellow:</p>
		<ol>
			<li>Select the concerned Ecore model in the Project Explorer</li>
			<li>Create a representation file by using the menu "File -&gt; New -&gt; Other ... Sirius -&gt; Representation File" and press "Next" button</li>
			<li>In the next page, make sure that the option "Initialize from semantic resource" is selected and pressing the "Finish" button</li>
			<li>In the Viewpoint selection dialog: 
				<ul>
					<li>Checking the viewpoint 
						<b>Extensibility</b>
					</li>
					<li>Pressing the Ok button</li>
				</ul>
			</li>
			<li>Right click on the created representation file (.aird) </li>
			<li>Select the "Create Representation" menu item</li>
			<li>In the "Create Representation Wizard", select Extensibility -&gt; Extensibility Description and press the "Next" button</li>
			<li>In the next page, select the EPackage containing the EClass to define as an Extension</li>
			<li>Press the "Finish" button</li>
			<li>In the displayed input dialog, provide the name of the new diagram and press "OK" button</li>
		</ol>
		<p><blockquote>
			Once the diagram created, the EAnnotation for the EPackage is automatically created.
</blockquote></p>
		<h3 id="Example">Example</h3>
		<p>Lets define the EClass <code>b.ComponentExtension</code> as an extension to the EClass <code>b.ComponentExtension</code>. The picture bellow shows an Extensibility diagram created on the EPackage <code>b</code>.</p>
		<p>
			<div class="thumb">
				<div class="thumbinner" style="width:502px;">
					<a href="../img/extension_description_designer.png" class="image">
						<img class="thumbimage" width="500" border="0" src="../img/extension_description_designer.png"/>
					</a>
				</div>
			</div>  
		</p>
		<p>
			<b>Step 1</b> 
		</p>
		<p>The tool 
			<i>Define Extension Element</i> allow to display the EClass <code>b.ComponentExtension</code> on the diagram (see picture bellow). Concretely, this tool add the ECLass <code>emde.ElementExtension</code> as a super type of the EClass <code>b.ComponentExtension</code> and the diagram display only EClasses that inherit from the EClass <code>b.ComponentExtension</code>.
		</p>
		<p>
			<div class="thumb">
				<div class="thumbinner" style="width:502px;">
					<a href="../img/extension_description_designer_step1.png" class="image">
						<img class="thumbimage" width="500" border="0" src="../img/extension_description_designer_step1.png"/>
					</a>
				</div>
			</div> 
		</p>
		<p>
			<b>Step 2</b> 
		</p>
		<p>Second, the tool 
			<i>Extend Model</i> allows to defines the EAnnotations to make the EClass <code>b.ComponentExtension</code> an extension to the EClass <code>b.ComponentExtension</code>. This tool end-user to select an extensible EClass and add the EAnnotations. The result on the diagram is shown in the picture bellow.
		</p>
		<p>
			<div class="thumb">
				<div class="thumbinner" style="width:502px;">
					<a href="../img/extension_description_designer_step2.png" class="image">
						<img class="thumbimage" width="500" border="0" src="../img/extension_description_designer_step2.png"/>
					</a>
				</div>
			</div> 
		</p>
		<p>
			<b>Result</b> 
		</p>
		<p>The pictures bellow show the B.ecore model before (left side) and after (right side) adding the required EAnnotation to define the EClass <code>b.ComponentExtension</code> as an extension of the class <code>a.Component</code>.</p>
		<table border="1">
			<tr>
				<td>
					<div class="thumb">
						<div class="thumbinner" style="width:402px;">
							<a href="../img/ecore_b.png" class="image">
								<img class="thumbimage" width="400" border="0" src="../img/ecore_b.png"/>
							</a>
						</div>
					</div> 
				</td>
				<td>
					<div class="thumb">
						<div class="thumbinner" style="width:502px;">
							<a href="../img/ecore_b_extension.png" class="image">
								<img class="thumbimage" width="500" border="0" src="../img/ecore_b_extension.png"/>
							</a>
						</div>
					</div> 
				</td>
			</tr>
		</table>
	</body>
</html>